package com.onlinelearn.userservice.controller;

import com.onlinelearn.userservice.dto.RegisterRequest;
import com.onlinelearn.userservice.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/auth")
public class AuthController {
    @Autowired
    private AuthService authService;

    @PostMapping("/register")
    public ResponseEntity<?> register(@RequestBody RegisterRequest request) {
        authService.register(request);
        return ResponseEntity.ok("注册成功");
    }

    @PostMapping("/login")
    public ResponseEntity<?> login(
        @RequestParam String email, 
        @RequestParam String password
    ) {
        authService.login(email, password);
        return ResponseEntity.ok("登录成功");
    }
} 